package com.example.leetdemo.finash;

public class Solution667 {

    public int[] constructArray(int n, int k) {
        int[] t = new int[n];
        for (int i = 0; i < n - k - 1; i++) {
            t[i] = i + 1;
        }
        for (int i = n - k - 1, j = n, l = n - k; i < n; ) {
            t[i] = l;
            i++;
            l++;
            if (i < n) {
                t[i] = j;
                i++;
                j--;
            }
        }
        return t;
    }

    public static void main(String[] args) {
        Solution667 solution667 = new Solution667();
        solution667.constructArray(5, 5);
    }
}
